<?
	require_once (dirname(__FILE__)."/../inc/conn.php");
	require_once ("userconfig.php");

function chklogin()
{
	global $db;
	$u_id = $_SESSION["userid"];
	if (!isN($u_id)){ 
		$row = $db->getRow("select * from tbl_user where u_id=". $u_id);
		$loginValidate = md5($row["u_random"] . $row["u_name"] . $row["u_id"]);
 
		if (!$row){
			$_SESSION["userid"]="";
			$_SESSION["usergourp"]="";
			$_SESSION["username"]="";
			$_SESSION["usercheck"]="";
	    	echo "<script>top.location.href='index.php?action=login';</script>";
	    	die("");
		}
		if ($_SESSION["usercheck"] != $loginValidate){
		   $_SESSION["usercheck"]="";
		   echo "<script>top.location.href='index.php?action=login';</script>";
		   die("");
		}
	}
	else{
		echo "<script>top.location.href='index.php?action=login';</script>";
		die("");
	}
}

?>